
#include <cassert>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
using namespace std;
struct Packet {
  int num_int{0};
  int num_double{0};
  int *int_data{nullptr};
  double *double_Data{nullptr};
};

// 下面两种方式都行
map<type_index, string> type_names;
// 
void CollectDataForPacket(Packet &pk) {}
template <typename T, typename... Types>
void CollectDataForPacket(Packet &pk, const T &t, const Types &... args) {
  auto iter = type_names.find(type_index(typeid(T)));
  if (iter != type_names.end()) {
    if (iter->second == "int") {
      pk.num_int++;
    } else if (iter->second == "double") {
      pk.num_double++;
    }
  }
  CollectDataForPacket(pk, args...);
}
//    这种方法只适合静态判断 对结构体封装的数据行不通
void c2(Packet &pk) {}
template <typename T, typename... Types>
void c2(Packet &pk, const T &t, const Types &... args) {
  if (is_integral<T>::value) {
    pk.num_int++;
  } else if (is_floating_point<T>::value) {
    pk.num_double++;
  }
  c2(pk, args...);
}

int main() {

  type_names[std::type_index(typeid(int))] = "int";
  type_names[std::type_index(typeid(double))] = "double";

  Packet pk;
  int a, b, c;
  double d, e;
  //   CollectDataForPacket(pk, a, b, c, d, e);
  c2(pk, a, b, c, d, e);
  cout << pk.num_int << "  " << pk.num_double << endl;
  cout << sizeof(bool) << endl;
  bool ddd = true;
  int iii = ddd;
  cout << iii << endl;
  return 0;
}